package com.demo.config.rabbitMq;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 交换机和队列基础-生产者
 *
 * @author admin
 */
@Configuration
public class RabbitConfigDirect {

	@Bean
	public Queue directQueue() {
		return new Queue("direct_queue");
	}

	@Bean
	public Queue directQueue2() {
		return new Queue("direct_queue");
	}

	@Bean
	public DirectExchange directExchange() {
		return new DirectExchange("directExchange");
	}

	// 绑定队列与交换机
	@Bean
	public Binding bindingDirect() {
		return BindingBuilder.bind(directQueue()).to(directExchange()).with("direct");
	}

	@Bean
	public Binding bindingDirect2() {
		return BindingBuilder.bind(directQueue2()).to(directExchange()).with("direct2");
	}

}
